package com.rc.saas.tenant.vo.ticket;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.rc.saas.tenant.common.annotation.Excel;

import java.text.SimpleDateFormat;

/**
 * @author wangzhengwei
 * @create 2021/6/30
 */
public class MemberTicketExcelVo {

    @Excel(title = "优惠券名称")
    private String ticketName;

    @Excel(title = "优惠券类型")
    private String ticketType;

    @Excel(title = "使用条件")
    private String  useRequireAmount;

//    @ExcelIgnore
//    private String discount;

    @Excel(title = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private String createdTime;

    @Excel(title = "昵称")
    private String nickname2;

    @Excel(title = "手机号")
    private String mobile;

    @Excel(title = "卡劵码")
    private Long memberTicketId;

    @Excel(title = "获得时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private String gainTime;

    @Excel(title = "生效时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private String effectStartDate;

    @Excel(title = "失效时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private String effectEndDate;

    @Excel(title = "状态")
    private String status;

    @Excel(title = "使用时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private String usedTime;

    public MemberTicketExcelVo(MemberTicketVo memberTicketVo) {
        this.ticketName = memberTicketVo.getTicketName();
        if("0".equals(memberTicketVo.getTicketType())){
            this.ticketType = "充电优惠卷";
        }else if ("1".equals(memberTicketVo.getTicketType())){
            this.ticketType = "整单优惠券";
        }
        this.useRequireAmount = "满" + memberTicketVo.getUseRequireAmount();
//        if ("0".equals(memberTicketVo.getDiscountType())){
//            this.discount =  "立减" + memberTicketVo.getDiscountAmount();
//        }else if("1".equals(memberTicketVo.getDiscountType())){
//            this.discount = memberTicketVo.getDiscount().intValue()*10 + "折";
//        }

        if (memberTicketVo.getCreatedTime() != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            this.createdTime = sdf.format(memberTicketVo.getCreatedTime());
        } else {
            this.createdTime = null;
        }
        this.nickname2 = memberTicketVo.getNickname2();
        this.mobile = memberTicketVo.getMobile();
        this.memberTicketId = memberTicketVo.getMemberTicketId();

        if (memberTicketVo.getGainTime() != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            this.gainTime = sdf.format(memberTicketVo.getGainTime());
        } else {
            this.gainTime = null;
        }

        if ("0".equals(memberTicketVo.getEffectType())){
            if (memberTicketVo.getGainTime() != null) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                this.effectStartDate = sdf.format(memberTicketVo.getGainTime());
            } else {
                this.effectStartDate = null;
            }
        }else if ("1".equals(memberTicketVo.getEffectType())){
            if (memberTicketVo.getEffectStartDate() != null) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                this.effectStartDate = sdf.format(memberTicketVo.getEffectStartDate());
            } else {
                this.effectStartDate = null;
            }
        }

        if (memberTicketVo.getEndTime() != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            this.effectEndDate = sdf.format(memberTicketVo.getEndTime());
        } else {
            this.effectEndDate = null;
        }

        if("0".equals(memberTicketVo.getStatus())){
            this.status = "未使用";
        }else if ("1".equals(memberTicketVo.getStatus())){
            this.status = "已使用";
        } else if ("2".equals(memberTicketVo.getStatus())){
            this.status = "过期";
        }

        if (memberTicketVo.getUsedTime() != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            this.usedTime = sdf.format(memberTicketVo.getUsedTime());
        } else {
            this.usedTime = null;
        }

    }

    public String getTicketName() {
        return ticketName;
    }

    public void setTicketName(String ticketName) {
        this.ticketName = ticketName;
    }

    public String getTicketType() {
        return ticketType;
    }

    public void setTicketType(String ticketType) {
        this.ticketType = ticketType;
    }

    public String getUseRequireAmount() {
        return useRequireAmount;
    }

    public void setUseRequireAmount(String useRequireAmount) {
        this.useRequireAmount = useRequireAmount;
    }

//    public String getDiscount() {
//        return discount;
//    }
//
//    public void setDiscount(String discount) {
//        this.discount = discount;
//    }

    public String getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(String createdTime) {
        this.createdTime = createdTime;
    }

    public String getEffectStartDate() {
        return effectStartDate;
    }

    public void setEffectStartDate(String effectStartDate) {
        this.effectStartDate = effectStartDate;
    }

    public String getEffectEndDate() {
        return effectEndDate;
    }

    public void setEffectEndDate(String effectEndDate) {
        this.effectEndDate = effectEndDate;
    }

    public String getGainTime() {
        return gainTime;
    }

    public void setGainTime(String gainTime) {
        this.gainTime = gainTime;
    }

    public String getUsedTime() {
        return usedTime;
    }

    public void setUsedTime(String usedTime) {
        this.usedTime = usedTime;
    }

    public String getNickname2() {
        return nickname2;
    }

    public void setNickname2(String nickname2) {
        this.nickname2 = nickname2;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Long getMemberTicketId() {
        return memberTicketId;
    }

    public void setMemberTicketId(Long memberTicketId) {
        this.memberTicketId = memberTicketId;
    }
}
